package com.xyh.reward_kotlin.api

import com.xyh.reward_kotlin.response.ApkVersionDto
import com.xyh.reward_kotlin.response.ResultDto
import com.xyh.reward_kotlin.response.RewardResultDto
import com.xyh.reward_kotlin.response.StudentDto
import com.xyh.reward_kotlin.response.Subject
import com.xyh.reward_kotlin.response.UserDto
import okhttp3.MultipartBody
import okhttp3.RequestBody
import okhttp3.ResponseBody
import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part
import retrofit2.http.Path
import retrofit2.http.Streaming

interface RewardApi {

    @POST("reward/calculate")
    fun calculateReward(@Body request: StudentDto): Call<RewardResultDto>

    @GET("reward/result")
    fun getResult(): Call<List<RewardResultDto>>

    @GET("reward/subjects")
    fun getSubjects(): Call<List<Subject>>

    @GET("reward/profile")
    fun getProfile(): Call<UserDto>

    @GET(value = "reward/last-version")
    fun getLastVersion(): Call<ResultDto<ApkVersionDto>>

    @DELETE("reward/{id}")
    fun deleteReward(@Path("id") id: Long): Call<ResultDto<Void>>

    @POST("reward/profile")
    fun updateProfile(@Body request: UserDto): Call<UserDto>

    @Multipart
    @POST("reward/avatar")
    fun updateAvatar(
        @Part file: MultipartBody.Part,
        @Part("id") userId: RequestBody
    ): Call<ResultDto<Int>>

    @GET("reward/download/{id}")
    @Streaming // 避免一次性读入内存
    fun downloadPdf(@Path("id") id: Long): Call<ResponseBody>
}
